package com.exam.service.impl;

import com.exam.mapper.AnswerMapper;
import com.exam.po.FillQuestion;
import com.exam.po.JudgeQuestion;
import com.exam.po.MultiQuestion;
import com.exam.service.AnswerService;
import com.exam.vo.AnswerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhanggaoxiang
 * @ClassName AnswerServiceImpl
 * @Description TODO
 * @Date 2021/1/12 10:47
 * @Version 1.0
 **/
@Service
public class AnswerServiceImpl implements AnswerService {
    @Autowired
   private AnswerMapper answerMapper;
    @Override
    public List<AnswerVO> findAnswerByPage(Integer page, Integer size) {
        return answerMapper.findAnswerByPage((page-1)*size,size);
    }

    @Override
    public int deleteFillQuesstionById(Integer questionId) {
        return answerMapper.deleteAnswerById(questionId);
    }

    /**
     * 教师分页查询题库
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<AnswerVO> findteacherAnswerByPage(Integer current, Integer size) {
        List<AnswerVO> answerVOS = answerMapper.findteacherAnswerByPage((current-1)*size, size);
        return answerVOS;
    }

    @Override
    public FillQuestion findFillQuesstionById(Integer questionId) {
        return answerMapper.findFillQuesstionById(questionId);
    }

    @Override
    public JudgeQuestion findJudegeQuesstionById(Integer questionId) {
        return answerMapper.findJudegeQuesstionById(questionId);
    }

    @Override
    public int deleteJudegeQuesstionById(Integer questionId) {
        return answerMapper.deleteJudegeQuesstionById(questionId);
    }

    @Override
    public MultiQuestion findMultiQuesstionById(Integer questionId) {
        return answerMapper.findMultiQuesstionById(questionId);
    }

    @Override
    public int deleteMultiQuesstionById(Integer questionId) {
        return answerMapper.deleteMultiQuesstionById(questionId);
    }

    /**
     * 查判断题总记录
     * @return
     */
    @Override
    public int countByJudgeQuestion() {

        return answerMapper.countByJudgeQuestion();
    }
    /**
     *查天空题总记录
     * @return
     */
    @Override
    public int countByFillQuestion() {
        return answerMapper.countByFillQuestion();
    }
    /**
     * 查选择题总记录
     * @return
     */
    @Override
    public int countByMultiQuestion() {
        return answerMapper.countByMultiQuestion();
    }
    @Override
    public Integer findAnswerCount() {
        Integer fillQuestionCount = answerMapper.findFillQuestionCount();
        Integer judgeQuestionCount = answerMapper.findJudgeQuestionCount();
        Integer multiQuestionCount = answerMapper.findMultiQuestionCount();
        Integer total=fillQuestionCount+judgeQuestionCount+multiQuestionCount;
        return total;
    }
}
